windows平台socket编程编译错误error C2065: ‘SOCKET‘ : undeclared identifier | 您所在的位置:网站首页 › c语言 c2065 › windows平台socket编程编译错误error C2065: ‘SOCKET‘ : undeclared identifier |
error C2065: 'SOCKET' : undeclared identifier LPFN_ACCEPTEX' : undeclared identifier error C2011: 'sockaddr_in' : 'struct' type redefinition 写代码的时候要用到SOCKET、LPFN_ACCEPTEX、WSA系列api,也就是会用到 #define WIN32_LEAN_AND_MEAN #include #include #include #include #pragma comment(lib, "ws2_32") 一开始不是这种include的顺序,也没有定义WIN32_LEAN_AND_MEAN,提示各种重定义和未定义 换成这种include顺序之后,重定义和未定义错误就没了。 Using the Windows Headers - Win32 apps | Microsoft Docs 根据微软官方的描述,定义WIN32_LEAN_AND_MEAN之后就不包含一些非必要的组件 You can reduce the size of the Windows header files by excluding some of the less common API declarations as follows: Define WIN32_LEAN_AND_MEAN to exclude APIs such as Cryptography, DDE, RPC, Shell, and Windows Sockets. #define WIN32_LEAN_AND_MEAN Define one or more of the NOapi symbols to exclude the API. For example, NOCOMM excludes the serial communication API. For a list of support NOapi symbols, see Windows.h. #define NOCOMM 这样编译会更小更快 可能还有区分宏定义的作用,加了这个宏之后,一些未定义的错误就没了 |
CopyRight 2018-2019 实验室设备网 版权所有 |